home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2005 Utilities / CHIP Utilities 2005.7z / CHIP Utilities 2005.iso / docs / freedos / www.briggsoft.com / visitor.js < prev   
Encoding:
Text File  |  2003-12-24  |  1.3 KB  |  45 lines

  1. function createCookie(name,value,days)
  2. {
  3.   if (days)
  4.   {
  5.     var date = new Date();
  6.     date.setTime(date.getTime()+(days*24*60*60*1000));
  7.     var expires = "; expires="+date.toGMTString();
  8.   }
  9.   else var expires = "";
  10.   document.cookie = name+"="+value+expires+"; path=/; domain=.briggsoft.com";
  11. }
  12.  
  13. function readCookie(name)
  14. {
  15.   var nameEQ = name + "=";
  16.   var ca = document.cookie.split(';');
  17.   for(var i=0;i < ca.length;i++)
  18.   {
  19.     var c = ca[i];
  20.     while (c.charAt(0)==' ') c = c.substring(1,c.length);
  21.     if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  22.   }
  23.   return null;
  24. }
  25.  
  26. if (!readCookie('visitor'))
  27. {
  28.   var today = new Date();
  29.   var month = today.getUTCMonth()+1;
  30.   var year = today.getUTCFullYear();
  31.   var day = today.getUTCDate();
  32.   var hour = today.getUTCHours();
  33.   var minute = today.getUTCMinutes();
  34.   var sec = today.getUTCSeconds();
  35.   if (sec<10) sec = '0' + sec;
  36.   if (minute<10) minute = '0' + minute;
  37.   if (hour<10) hour = '0' + hour;
  38.   if (day<10) day = '0' + day;
  39.   if (month<10) month = '0' + month;
  40.   var ref = document.referrer;
  41.   if (ref == '') ref = 'none';
  42.   var newcookie = escape(year+'-'+month+'-'+day+' '+hour+':'+minute+':'+sec+'|'+document.URL+'|'+ref);
  43.   createCookie('visitor',newcookie,365);
  44. }
  45.